/********************************************************************************
* Description: udp interface wrapper
* Author: hsqiang
* Create Date: 2023-06-21
********************************************************************************/
#ifndef UDP_SERVICE_HPP_
#define UDP_SERVICE_HPP_

#include "net_service.hpp"
#include "channel.hpp"
#include <memory>

namespace event_framework
{
    class UdpService : public NetService
    {
    public:
        UdpService(EventLoop& loop, const EndPoint& ep) : NetService(loop, ep) {}
        virtual ~UdpService() = default;
        virtual bool Init() override;
        virtual bool Fini() override
        {
            loop.Accept(std::bind(&UdpService::FiniChannel, this));
        }
    private:
        void InitChannel();
        void FiniChannel() { channel->DisableAll(); }
        
        ChannelPtr channel;
    };
}

#endif